package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;


@Mapper
public interface DishMapper {
    //添加菜品
    //@Options(useGeneratedKeys = true,keyProperty = "id")//获取主键值，并赋值给id属性
    @AutoFill(OperationType.INSERT)
    void addDish(Dish dish);
    //菜品分页查询
    Page<DishVO> page(DishPageQueryDTO dto);
    //根据id查询菜品状态
    Dish selectById(Long id);
    //批量删除菜品
    void deleteBatch(List<Long> ids);
    //修改菜品
    @AutoFill(OperationType.UPDATE)
    void update(Dish dish);
    //根据分类id查询菜品
    @Select("select * from dish where category_id=#{categoryId}")
     List<DishVO>  getByCategoryId(Long categoryId);

    List<Dish> list(Dish dish);
    //菜品的起售停售
    @Update("update dish set status=#{status} where id=#{id}")
    void updateDishStatus(Long status, Long id);
    @Select("select * from dish where id=#{dishId}")
    Dish getById(Long dishId);
    /**
     * 根据条件统计套餐数量
     * @param map
     * @return
     */
    Integer countByMap(Map map);
}

